<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>books_manage</title>
    <link rel="stylesheet" href="/static/css/index.css">
    <link rel="stylesheet" href="/static/css/books_list.css">
    <link rel="stylesheet" href="/static/css/books_manage.css">
    <script type="text/javascript" src="/static/js/jquery-1.7.2.js"></script>
    {{/*<script>
        $(function (){
            $(".deleteBook").click(function (){
                var id=$(this).attr("id");
                var url="/deleteBook";
                var param={"bookId":id};
                $.get(url,param,function(res){
                    if(res == "这本书已经被借，无法删除"){
                        alert(res);
                    }
                });
            });
        });
    </script>*/}}
</head>
<body>
<div class="header">
    {{if .IsLogin}}
        <div>
            管理员：{{.Username}}
        </div>
        <div>
            <a href="/queryBookById">新书上架</a>
            <a href="/logout">注销</a>
            <a href="/getBookByPage">图书管理</a>
            <a href="/getAllUser">用户管理</a>
            <a href="/main">返回</a>
        </div>
    {{else}}
        你还未登录<a href="/main">返回</a>
    {{end}}
</div>
<div id="main">
    <div class="books_list">
        {{range .Book}}
            <div class="img_div"><img src="{{.ImgPath}}" width="100px"></div>
            <div class="info_div">
                <p>书名:{{.Title}}</p>
                <p>作者:{{.Author}}</p>
                <p>出版社:{{.Publish}}</p>
                <p>定价:{{.Price}}</p>
                <p>借阅数量:{{.Borrow}}</p>
                <p>剩余数量:{{.Remain}}</p>
                <a class="reviseBook" href="/queryBookById?bookId={{.Id}}">修改</a>
                <a class="deleteBook" id="{{.Id}}" href="/deleteBookById?bookId={{.Id}}">删除</a>
{{/*                <button id="{{.Id}}" class="reviseBook">修改</button>*/}}
{{/*                <button id="{{.Id}}" class="deleteBook">删除</button>*/}}
            </div>
        {{end}}
    </div>
    <div>
        {{if .IsHaveLast}}
            <a href="/getBookByPage">首页</a>
            <a href="/getBookByPage?currentPage={{.GoLast}}">上一页</a>
        {{end}}
        当前是{{.CurrentPage}}页,一共{{.TotalPages}}页,共{{.TotalRows}}记录
        {{if .IsHaveNext}}
            <a href="/getBookByPage?currentPage={{.GoNext}}">下一页</a>
            <a href="/getBookByPage?currentPage={{.TotalPages}}">末页</a>
        {{end}}
        到<input type="text" value="{{.CurrentPage}}" name="cp" id="cp_input">页
        <input type="submit" value="确定" id="sub">
        <script>
            $("#sub").click(function (){
                var currentPage = $("#cp_input").val();
                if(currentPage<={{.TotalPages}}){
                    location = "/getBookByPage?currentPage="+currentPage;
                }else{
                    alert("最大页是"+"{{.TotalPages}}")
                }
            });
        </script>
    </div>
</div>
</body>
</html>